package com.gjy.util.concurrent;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-06-17 17:46:47
 */
public class FileUtil {

    public static List<String> splitSqlFile(String filePath) throws Exception {
        String content = new String(Files.readAllBytes(Paths.get(filePath)), StandardCharsets.UTF_8);
        // 按分号分割，并保留分号
        String[] parts = content.split("(?<=;)");
        List<String> sqlList = new ArrayList<>();
        for (String part : parts) {
            String sql = part.trim();
            if (!sql.isEmpty()) {
                sqlList.add(sql);
            }
        }
        return sqlList;
    }

}
